package turing.forum.web.controller.forum;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import turing.forum.common.controller.BaseController;
import turing.forum.common.domain.AjaxResult;
import turing.forum.common.domain.ResultsList;
import turing.forum.repository.po.User;
import turing.forum.repository.po.UserShare;
import turing.forum.service.impl.ShareService;
import turing.forum.web.vo.UserShareVo;

@RestController
@RequestMapping("/forum/share")
public class ShareController extends BaseController {

    @Autowired
    private ShareService shareService;

    @RequestMapping("/list")
    private ResultsList listShares(User user, Integer pageNum, Integer pageSize) {
        Page<UserShare> userSharePage = shareService.listShares(
                user,
                pageNum != null ? pageNum : 1,
                pageSize != null ? pageSize : 10
        );
        return getResultsList(userSharePage);
    }

    @RequestMapping("/share")
    private AjaxResult addShare(UserShareVo shareVo) {

        return AjaxResult.success("share successfully");
    }
}
